//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.IO;
using OpenLS.Spreadsheet.Expressions;

namespace OpenLS.Spreadsheet.Formats.Biff.Tokens
{
    internal class AreaError3DToken : FormulaToken
    {
        private readonly AccessorType _type;
        private ushort sheetId;
        private ulong notUsed;

        public AreaError3DToken(AccessorType type)
        {
            _type = type;
        }

        public override ushort GetLength(FormulaReadContextType formulaReadContextType)
        {
            return 10;
        }
        public override FormulaTokenId TokenId
        {
            get { switch (_type)
            {
                case AccessorType.Array:
                    return FormulaTokenId.AreaErr3dA;
                case AccessorType.Reference:
                    return FormulaTokenId.AreaErr3d;
                    case AccessorType.Value:
                    return FormulaTokenId.AreaErr3dV;
                default: throw new NotSupportedException();
            }}
        }
        internal override void ReadContent(FormulaReadContext context)
        {
            this.sheetId = context.ReadUInt16();
            this.notUsed = context.ReadUInt64();
            ;
        }

        internal override Expression GetExpression(FormulaEvaluationContext context)
        {
            return new ErrorExpression(Errors.RefError);
        }

        public override void WriteContent(FormulaWriteContext context)
        {
            context.WriteUInt16(sheetId);
            context.Writer.Write(notUsed);
        }
    }
}